{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "6e8f0d92",
   "metadata": {},
   "source": [
    "# Using PlasmaPy Particles"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "0c7eeced",
   "metadata": {},
   "source": [
    "[plasmapy.particles]: ../../particles/index.rst\n",
    "\n",
    "The [plasmapy.particles] subpackage contains functions to access basic particle data and classes to represent particles."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "24125310",
   "metadata": {},
   "outputs": [],
   "source": [
    "from plasmapy.particles import (\n",
    "    CustomParticle,\n",
    "    DimensionlessParticle,\n",
    "    Particle,\n",
    "    ParticleList,\n",
    "    atomic_number,\n",
    "    charge_number,\n",
    "    element_name,\n",
    "    half_life,\n",
    "    is_stable,\n",
    "    molecule,\n",
    "    particle_mass,\n",
    ")\n",
    "from plasmapy.particles.particle_class import valid_categories"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "650d57e8",
   "metadata": {},
   "source": [
    "## Contents\n",
    "\n",
    "1. [Particle properties](#Particle-properties)\n",
    "2. [Particle objects](#Particle-objects)\n",
    "3. [Custom particles](#Custom-particles)\n",
    "4. [Molecules](#Molecules)\n",
    "5. [Particle lists](#Particle-lists)\n",
    "6. [Dimensionless particles](#Dimensionless-particles)\n",
    "7. [Nuclear reactions](#Nuclear-reactions)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "e224284a",
   "metadata": {},
   "source": [
    "## Particle properties"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "7696deba",
   "metadata": {},
   "source": [
    "[representation of a particle]: https://docs.plasmapy.org/en/stable/api/plasmapy.particles.ParticleLike.html#particlelike\n",
    "\n",
    "There are several functions that provide information about different particles that might be present in a plasma. The input of these functions is a [representation of a particle], such as a string for the atomic symbol or the element name."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "006b8d3e",
   "metadata": {},
   "outputs": [],
   "source": [
    "atomic_number(\"Fe\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "2aa5af34",
   "metadata": {},
   "source": [
    "[atomic number]: https://en.wikipedia.org/wiki/Atomic_number\n",
    "\n",
    "We can provide a number that represents the [atomic number]."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "69958326",
   "metadata": {},
   "outputs": [],
   "source": [
    "element_name(26)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "cca89cef",
   "metadata": {},
   "source": [
    "We can also provide standard symbols or the names of particles."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "16ca5b6f",
   "metadata": {},
   "outputs": [],
   "source": [
    "is_stable(\"e-\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "35d8e49e",
   "metadata": {},
   "outputs": [],
   "source": [
    "charge_number(\"proton\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "e498e01e",
   "metadata": {},
   "source": [
    "[alpha particle]: https://en.wikipedia.org/wiki/Alpha_particle\n",
    "\n",
    "The symbols for many particles can even be used directly, such as for an [alpha particle]. To create an \"α\" in a Jupyter notebook, type `\\alpha` and press tab."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "493a2d6f",
   "metadata": {},
   "outputs": [],
   "source": [
    "particle_mass(\"α\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "8f2e5b30",
   "metadata": {},
   "source": [
    "[mass number]: https://en.wikipedia.org/wiki/Mass_number\n",
    "[half_life]: ../../api/plasmapy.particles.atomic.half_life.rst\n",
    "[Quantity]: https://docs.astropy.org/en/stable/units/quantity.html#quantity\n",
    "[astropy.units]: https://docs.astropy.org/en/stable/units/index.html\n",
    "\n",
    "We can represent isotopes with the atomic symbol followed by a hyphen and the [mass number]. In this example, [half_life] returns the time in seconds as a [Quantity] from [astropy.units]."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "94fcf452",
   "metadata": {},
   "outputs": [],
   "source": [
    "half_life(\"C-14\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "58ab7782",
   "metadata": {},
   "source": [
    "We typically represent an ion in a string by putting together the atomic symbol or isotope symbol, a space, the charge number, and the sign of the charge."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "a65e15da",
   "metadata": {},
   "outputs": [],
   "source": [
    "charge_number(\"Fe-56 13+\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ce4886cf",
   "metadata": {},
   "source": [
    "[plasmapy.particles]: ../../particles/index.rst\n",
    "[Particle]: ../../api/plasmapy.particles.particle_class.Particle.rst\n",
    "[particle-like]: https://docs.plasmapy.org/en/latest/glossary.html#term-particle-like\n",
    "\n",
    "Functions in [plasmapy.particles] are quite flexible in terms of string inputs representing particles. An input is [particle-like] if it can be transformed into a [Particle].  "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "05e03a8b",
   "metadata": {},
   "outputs": [],
   "source": [
    "particle_mass(\"iron-56 +13\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "0dd9541b",
   "metadata": {},
   "outputs": [],
   "source": [
    "particle_mass(\"iron-56+++++++++++++\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "d3adf3a6",
   "metadata": {},
   "source": [
    "Most of these functions take additional arguments, with `Z` representing the charge number of an ion and `mass_numb` representing the mass number of an isotope. These arguments are often [keyword-only](https://docs.plasmapy.org/en/latest/glossary.html#term-keyword-only) to avoid ambiguity."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "61e0f960",
   "metadata": {},
   "outputs": [],
   "source": [
    "particle_mass(\"Fe\", Z=13, mass_numb=56)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "53a1d993",
   "metadata": {},
   "source": [
    "## Particle objects"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "3c2c3835",
   "metadata": {},
   "source": [
    "[Particle]: ../../api/plasmapy.particles.particle_class.Particle.rst\n",
    "\n",
    "Up until now, we have been using functions that accept representations of particles and then return particle properties. With the [Particle] class, we can create objects that represent physical particles."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "fe9f824a",
   "metadata": {},
   "outputs": [],
   "source": [
    "proton = Particle(\"p+\")\n",
    "electron = Particle(\"electron\")\n",
    "iron56_nuclide = Particle(\"Fe\", Z=26, mass_numb=56)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "160df55b",
   "metadata": {},
   "source": [
    "[Particle]: ../../api/plasmapy.particles.particle_class.Particle.rst\n",
    "\n",
    "Particle properties can be accessed via attributes of the [Particle] class."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "bebcc477",
   "metadata": {},
   "outputs": [],
   "source": [
    "proton.mass"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "df0f2eed",
   "metadata": {},
   "outputs": [],
   "source": [
    "electron.charge"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "116cd6ad",
   "metadata": {},
   "outputs": [],
   "source": [
    "electron.charge_number"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "99d22bd3",
   "metadata": {},
   "outputs": [],
   "source": [
    "iron56_nuclide.nuclear_binding_energy"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "8986cef8",
   "metadata": {},
   "source": [
    "### Antiparticles\n",
    "\n",
    "[Particle]: ../../api/plasmapy.particles.particle_class.Particle.rst\n",
    "\n",
    "We can get antiparticles of fundamental particles by using the `antiparticle` attribute of a [Particle]."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "f6663952",
   "metadata": {},
   "outputs": [],
   "source": [
    "electron.antiparticle"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "bf40e592",
   "metadata": {},
   "source": [
    "[Particle]: ../../api/plasmapy.particles.particle_class.Particle.rst\n",
    "\n",
    "We can also use the tilde operator on a [Particle] to get its antiparticle."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "180a1edf",
   "metadata": {},
   "outputs": [],
   "source": [
    "~proton"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "8500bc48",
   "metadata": {},
   "source": [
    "### Ionization and recombination\n",
    "\n",
    "[Particle]: ../../api/plasmapy.particles.particle_class.Particle.rst\n",
    "\n",
    "The `recombine` and `ionize` methods of a [Particle] representing an ion or neutral atom will return a different [Particle] with fewer or more electrons."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "186b1dfa",
   "metadata": {},
   "outputs": [],
   "source": [
    "deuterium = Particle(\"D 0+\")\n",
    "deuterium.ionize()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "4ee95241",
   "metadata": {},
   "source": [
    "When provided with a number, these methods tell how many bound electrons to add or remove."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "242b53bd",
   "metadata": {},
   "outputs": [],
   "source": [
    "alpha = Particle(\"alpha\")\n",
    "alpha.recombine(2)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "8ebf2176",
   "metadata": {},
   "source": [
    "[Particle]: ../../api/plasmapy.particles.particle_class.Particle.rst\n",
    "\n",
    "If the ``inplace`` keyword is set to `True`, then the [Particle] will be replaced with the new particle."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "bb2716c0",
   "metadata": {},
   "outputs": [],
   "source": [
    "argon = Particle(\"Ar 0+\")\n",
    "argon = argon.ionize()\n",
    "print(argon)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "e5302bef",
   "metadata": {},
   "source": [
    "## Custom particles"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "4c8c2a63",
   "metadata": {},
   "source": [
    "[CustomParticle]: ../../api/plasmapy.particles.particle_class.CustomParticle.rst\n",
    "\n",
    "Sometimes we want to use a particle with custom properties.  For example, we might want to represent an average ion in a multi-species plasma.  For that we can use [CustomParticle]."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "35b94505",
   "metadata": {},
   "outputs": [],
   "source": [
    "import astropy.constants as const\n",
    "import astropy.units as u\n",
    "\n",
    "custom_particle = CustomParticle(9.27e-26 * u.kg, 13.6 * const.e.si, symbol=\"Fe 13.6+\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "dfc19404",
   "metadata": {},
   "source": [
    "[CustomParticle]: ../../api/plasmapy.particles.particle_class.CustomParticle.rst\n",
    "[Particle]: ../../api/plasmapy.particles.particle_class.Particle.rst\n",
    "\n",
    "Many of the attributes of [CustomParticle] are the same as in [Particle]."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "8a4b412b",
   "metadata": {},
   "outputs": [],
   "source": [
    "custom_particle.mass"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "a2da2b3b",
   "metadata": {},
   "outputs": [],
   "source": [
    "custom_particle.charge"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "ecb450f6",
   "metadata": {},
   "outputs": [],
   "source": [
    "custom_particle.symbol"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "21a992a9",
   "metadata": {},
   "source": [
    "[nan]: https://numpy.org/doc/stable/reference/constants.html#numpy.nan\n",
    "\n",
    "If we do not include one of the physical quantities, it gets set to [nan] (not a number) in the appropriate units."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "a31c421a",
   "metadata": {},
   "outputs": [],
   "source": [
    "CustomParticle(9.27e-26 * u.kg).charge"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "6292a1f3",
   "metadata": {},
   "source": [
    "[CustomParticle]: ../../api/plasmapy.particles.particle_class.CustomParticle.rst\n",
    "[plasmapy.formulary]: ../../formulary/index.rst\n",
    "[plasmapy.particles]: ../../particles/index.rst\n",
    "\n",
    "[CustomParticle] objects are not yet able to be used by many of the functions in [plasmapy.formulary], but are expected to become compatible with them in a future release of PlasmaPy. Similarly, [CustomParticle] objects are not able to be used by the functions in [plasmapy.particles] that require that the particle be real."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "0f2b0634",
   "metadata": {},
   "source": [
    "## Particle lists"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "7939cfad",
   "metadata": {},
   "source": [
    "[ParticleList]: ../../api/plasmapy.particles.particle_collections.ParticleList.rst\n",
    "[Particle]: ../../api/plasmapy.particles.particle_class.Particle.rst\n",
    "[CustomParticle]: ../../api/plasmapy.particles.particle_class.CustomParticle.rst\n",
    "\n",
    "The [ParticleList] class is a container for [Particle] and [CustomParticle] objects."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "30cc7d36",
   "metadata": {},
   "outputs": [],
   "source": [
    "iron_ions = ParticleList([\"Fe 12+\", \"Fe 13+\", \"Fe 14+\"])"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "d56ddb98",
   "metadata": {},
   "source": [
    "[ParticleList]: ../../api/plasmapy.particles.particle_collections.ParticleList.rst\n",
    "\n",
    "By using a [ParticleList], we can access the properties of multiple particles at once."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "2434f71b",
   "metadata": {},
   "outputs": [],
   "source": [
    "iron_ions.mass"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "14a431dd",
   "metadata": {},
   "outputs": [],
   "source": [
    "iron_ions.charge"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "48cd1c7a",
   "metadata": {},
   "outputs": [],
   "source": [
    "iron_ions.symbols"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "cccc6c60",
   "metadata": {},
   "source": [
    "[ParticleList]: ../../api/plasmapy.particles.particle_collections.ParticleList.rst\n",
    "[Particle]: ../../api/plasmapy.particles.particle_class.Particle.rst\n",
    "[CustomParticle]: ../../api/plasmapy.particles.particle_class.CustomParticle.rst\n",
    "\n",
    "We can also create a [ParticleList] by adding [Particle] and/or [CustomParticle] objects together."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "3b953065",
   "metadata": {},
   "outputs": [],
   "source": [
    "proton + electron + custom_particle"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "f1ed1dc2",
   "metadata": {},
   "source": [
    "## Molecules"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "72bb94e5",
   "metadata": {},
   "source": [
    "[CustomParticle]: ../../api/plasmapy.particles.particle_class.CustomParticle.rst\n",
    "[molecule]: ../../api/plasmapy.particles.particle_class.molecule.rst\n",
    "\n",
    "We can use [molecule] to create a [CustomParticle] based on a chemical formula. The first argument to [molecule] is a string that represents a chemical formula, except that the subscript numbers are not given as subscripts. For example, water is ``\"H2O\"``.  "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "da22120e",
   "metadata": {},
   "outputs": [],
   "source": [
    "water = molecule(\"H2O\")\n",
    "water.symbol"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ff5a6cf1",
   "metadata": {},
   "source": [
    "The properties of the molecule are found automatically."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "1ae6284a",
   "metadata": {},
   "outputs": [],
   "source": [
    "water.mass"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "23c42034",
   "metadata": {},
   "outputs": [],
   "source": [
    "acetic_acid_anion = molecule(\"CH3COOH 1-\")\n",
    "acetic_acid_anion.charge"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ebc037f7",
   "metadata": {},
   "source": [
    "## Particle categorization"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "f298538f",
   "metadata": {},
   "source": [
    "[categories]: ../../api/plasmapy.particles.particle_class.Particle.rst#plasmapy.particles.particle_class.Particle.categories\n",
    "[Particle]: ../../api/plasmapy.particles.particle_class.Particle.rst\n",
    "\n",
    "The [categories] attribute of a [Particle] provides a set of the categories that the [Particle] belongs to."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "09f122ff",
   "metadata": {},
   "outputs": [],
   "source": [
    "muon = Particle(\"muon\")\n",
    "muon.categories"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "934739a8",
   "metadata": {},
   "source": [
    "[is_category()]: ../../api/plasmapy.particles.particle_class.Particle.rst#plasmapy.particles.particle_class.Particle.is_category\n",
    "[Particle]: ../../api/plasmapy.particles.particle_class.Particle.rst\n",
    "\n",
    "The [is_category()] method lets us determine if a [Particle] belongs to one or more categories."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "d278fa15",
   "metadata": {},
   "outputs": [],
   "source": [
    "muon.is_category(\"lepton\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "6edf5cc1",
   "metadata": {},
   "source": [
    "[Particle]: ../../api/plasmapy.particles.particle_class.Particle.rst\n",
    "\n",
    "If we need to be more specific, we can use the `require` keyword for categories that a [Particle] must belong to, the `exclude` keyword for categories that the [Particle] cannot belong to, and the `any_of` keyword for categories of which a [Particle] needs to belong to at least one."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "5b5e6ee7",
   "metadata": {},
   "outputs": [],
   "source": [
    "electron.is_category(require=\"lepton\", exclude=\"baryon\", any_of={\"boson\", \"fermion\"})"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "a03c8153",
   "metadata": {},
   "source": [
    "[valid_categories]: ../../api/plasmapy.particles.particle_class.valid_categories.rst\n",
    "\n",
    "All valid particle categories are included in [valid_categories]."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "f57d6333",
   "metadata": {},
   "outputs": [],
   "source": [
    "print(valid_categories)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "a47471b5",
   "metadata": {},
   "source": [
    "[is_category()]: ../../api/plasmapy.particles.particle_class.Particle.rst#plasmapy.particles.particle_class.Particle.is_category\n",
    "[ParticleList]: ../../api/plasmapy.particles.particle_collections.ParticleList.rst\n",
    "\n",
    "The [is_category()] method of [ParticleList] returns a `list` of boolean values which correspond to whether or not each particle in the list meets the categorization criteria."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "0973c148",
   "metadata": {},
   "outputs": [],
   "source": [
    "particles = ParticleList([\"e-\", \"p+\", \"n\"])\n",
    "particles.is_category(require=\"lepton\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "df2415de",
   "metadata": {},
   "source": [
    "## Dimensionless particles"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "a1af4fc4",
   "metadata": {},
   "source": [
    "[DimensionlessParticle]: ../../api/plasmapy.particles.particle_class.DimensionlessParticle.rst\n",
    "\n",
    "When we need a dimensionless representation of a particle, we can use the [DimensionlessParticle] class."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "f57a0f64",
   "metadata": {},
   "outputs": [],
   "source": [
    "dimensionless_particle = DimensionlessParticle(mass=0.000545, charge=-1)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "cf598cb0",
   "metadata": {},
   "source": [
    "The properties of dimensionless particles may be accessed by its attributes."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "7b0f9755",
   "metadata": {},
   "outputs": [],
   "source": [
    "dimensionless_particle.mass"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "d4920b68",
   "metadata": {},
   "outputs": [],
   "source": [
    "dimensionless_particle.charge"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "29e23e5f",
   "metadata": {},
   "source": [
    "[DimensionlessParticle]: ../../api/plasmapy.particles.particle_class.DimensionlessParticle.rst\n",
    "[ParticleList]: ../../api/plasmapy.particles.particle_collections.ParticleList.rst\n",
    "\n",
    "Because a [DimensionlessParticle] does not uniquely describe a physical particle, it cannot be contained in a [ParticleList].  "
   ]
  },
  {
   "cell_type": "markdown",
   "id": "efe199c8",
   "metadata": {},
   "source": [
    "## Nuclear reactions"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "58fb006b",
   "metadata": {},
   "source": [
    "[plasmapy.particles]: ../../particles/index.rst\n",
    "\n",
    "We can use [plasmapy.particles] to calculate the energy of a nuclear reaction using the `>` operator.  "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "d8a9ab9e",
   "metadata": {},
   "outputs": [],
   "source": [
    "deuteron = Particle(\"D+\")\n",
    "triton = Particle(\"T+\")\n",
    "alpha = Particle(\"α\")\n",
    "neutron = Particle(\"n\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "cb95c644",
   "metadata": {},
   "outputs": [],
   "source": [
    "energy = deuteron + triton > alpha + neutron"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "e7a4c236",
   "metadata": {},
   "outputs": [],
   "source": [
    "energy.to(\"MeV\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "8bf7e515",
   "metadata": {},
   "source": [
    "If the nuclear reaction is invalid, then an exception is raised that states the reason why."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "efff1677",
   "metadata": {
    "nbsphinx": "hidden"
   },
   "outputs": [],
   "source": [
    "%xmode minimal"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "67b32a3a",
   "metadata": {
    "tags": [
     "raises-exception"
    ]
   },
   "outputs": [],
   "source": [
    "deuteron + triton > alpha + 3 * neutron"
   ]
  }
 ],
 "metadata": {
  "celltoolbar": "Tags",
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
